
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
    <%@ page import="com.exam.domain.*"%>
    <%@ page import="java.sql.*"%>
    <%@page import="exam.Catalog" %>
    <%@ page import="java.util.ArrayList" %>
    <%@ page import="java.util.List"%>
     <%Instructor ins= (Instructor)session.getAttribute("insinfo"); %>
    <%

    	Connection con= null;
    	Statement stmt= null;
    	ResultSet rs= null;	
    	ResultSet rs1=null;	
    	
    	try{
		DriverManager.registerDriver(new com.mysql.jdbc.Driver());//注册驱动
			con= DriverManager.getConnection(
			"jdbc:mysql://localhost:3306/ex","root","admin");
		stmt = con.createStatement();
		String i_id=ins.getI_id();
		String sql="SELECT course_id,course_name FROM teaches natural join course where i_id='"+i_id+"' and isDel=0";
		rs= stmt.executeQuery(sql);
    		%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>e-exam</title>



<script type="text/javascript"> 
	function refresh()
	{
		 var courseid= document.form1.course_id.value;
  		document.form1.action="servlet/TemplateServlet?submit=false&type=add&course_id="+courseid;
  		document.form1.submit();
		
		
	//	window.self.location = "servlet/TemplateServlet?submit=false&course_id=" + document.getElementsById("course_id");
	}
</script> 
</head>



<body>
<p>&quot;<img src="e-exam.gif" width="680" height="170" /></p>
<p>&nbsp;</p>

<h1>添加新试题模版<br /></h1>

<form id="form1" name="form1" method="post" action="servlet/TemplateServlet?submit=true&type=add">
     
        <label for="textarea"></label>
        <label for="textarea4"></label>
   
       
  <h2>选择所属课程</h2>
  <select name="course_id"  >
   <%

   while(rs.next()){
   		 String c_id=rs.getString("course_id");String c_name=rs.getString("course_name");
   		out.println("<option value="+c_id+">"+c_name+"</option>"); }
   		String re="false";
   		re=(String)session.getAttribute("is_refresh");
   %>
  </select>
  	  <input type="button" onclick="refresh()" value="刷新">
 <h2>模版名称<br/></h2><input type="text" name="template_name" />
	
	  <h2>课程知识点列表</h2>

  <table width="385" border="1" cellspacing="1">
    <tr>
      <th width="23" scope="col">&nbsp;</th>
      <th width="267" scope="col">知识点名称</th>
      <th width="77" scope="col">客观题数</th>
      <th width="77" scope="col">主观题数</th>
    </tr>
<% 	
		if(re!=null)
{		List<Catalog> listOfCat;

		listOfCat=(List<Catalog>)session.getAttribute("list_of_cat");
		
		if(!listOfCat.isEmpty())	
		for(int i=0;i<listOfCat.size();i++)
		{
			Catalog cat=listOfCat.get(i);
			out.println("<tr><td><input name=catalog_id type=checkbox value="+cat.getCatalog_id()+" /></td>");
			out.println("<td>"+cat.getCatalog_name()+"</td>");
			out.println("<td><div align=center><select name=number_of_choice>");
			for(int j=0;j<=cat.getNum_of_choice();j++)
			{
				out.println("<option value="+j+">"+j+"</option>");
			}
			out.println("</select></div></td>");
			out.println("<td><div align=center><select name=number_of_sub>");
			for(int j=0;j<=cat.getNum_of_sub();j++)
			{
				out.println("<option value="+j+">"+j+"</option>");
			}
			out.println("</select></div></td></tr>");
		}}
%>
  </table> 
  <p>设定客观题的分值</p>
    <select name="choice_question_score">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>
    <p>设定主观题的分值</p>
    <select name="sub_question_score">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
      <option value="5">5</option>
    </select>

  <p>
    <input name="button" type="submit" id="button" value="保存" />
        <input type="reset" name="button2" id="button2" value="重置" />
  </p>
</form>
<p>&nbsp;</p>
<p><a href="tea_qb.jsp">返回题库管理</a></p>
</body>
</html>
  <%    	session.setAttribute("is_refresh",null); }
  catch(Exception sqlex1)
{sqlex1.printStackTrace();}
finally { 
	if (con != null)
	{
		try { con.close();
		}catch (SQLException sqlex2)
		{sqlex2.printStackTrace();}
	}
	}
  %>
